package com.he.hsdyc.config.oss;

import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSSClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(OssProperties.class)
public class OssConfig {

    @Autowired
    private OssProperties ossProperties;

    @Bean
    public OSSClient getOSSClient(){

        ClientConfiguration conf=new ClientConfiguration();
        // Set the maximum number of allowed open HTTP connections
        conf.setMaxConnections(1000);
        conf.setConnectionTimeout(600000);
        conf.setSocketTimeout(600000);



        OSSClient client = new OSSClient(ossProperties.getEndpoint(),ossProperties.getAccessKeyId(),ossProperties.getAccessKeySecret(),conf);
        return client;
    }

}
